Skip to content

Hydrate dashboard creator emails from Supabase auth#334

Merged
ben-fornefeld merged 4 commits into
mainfrom
pr-15-hydrate-dashboard-user-emails-from-supabase-auth-eng-4086
May 19, 2026
Merged

Hydrate dashboard creator emails from Supabase auth#334
ben-fornefeld merged 4 commits into
mainfrom
pr-15-hydrate-dashboard-user-emails-from-supabase-auth-eng-4086

Conversation

@ben-fornefeld

Copy link
Copy Markdown
Member

Motivation

Infra API creator email fields are being deprecated as public.users moves away from storing profile data. Dashboard keeps creator email display working by falling back to Supabase Auth only when the API response does not include an email.

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings May 19, 2026 00:26
@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment May 19, 2026 1:06am
web-juliett Ready Ready Preview, Comment May 19, 2026 1:06am

Request Review

@linear-code

linear-code Bot commented May 19, 2026

Copy link
Copy Markdown

ENG-4086

@cla-bot cla-bot Bot added the cla-signed label May 19, 2026
@cursor

cursor Bot commented May 19, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Medium risk because it changes server-side repository responses and can overwrite createdBy.email with null when the auth lookup returns no entry or fails to include a user id.

Overview
Email hydration always replaces createdBy.email from the Supabase Auth lookup, so existing API-provided emails can be overwritten and missing lookups can turn emails into null instead of only falling back when absent.

Reviewed by Cursor Bugbot for commit 5077f02. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a fallback path that resolves missing creator emails on API key and template lists by querying the Supabase auth_users view, in preparation for the Infra API deprecating creator email fields.

Changes:

  • New auth-user-emails.server.ts module with getAuthUserEmailsById (queries Supabase admin) and a generic resolveMissingCreatorEmails helper that hydrates createdBy.email only for items missing one, silently falling back to original data on lookup failure.
  • Keys and templates repositories accept an injectable resolveAuthUserEmailsById dep and use resolveMissingCreatorEmails on list/create results; createApiKey also guards against a missing res.data.
  • New unit test covering listTeamApiKeys hydration and graceful degradation when the lookup throws.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/core/modules/users/auth-user-emails.server.ts New helper to batch-fetch auth emails and hydrate missing createdBy.email fields
src/core/modules/keys/repository.server.ts Wires hydration into listTeamApiKeys/createApiKey and adds a null-data guard
src/core/modules/templates/repository.server.ts Wires hydration into template listing
tests/unit/keys-repository.test.ts New tests covering hydration and lookup-failure fallback

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/modules/keys/repository.server.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fb3c547. Configure here.

Comment thread src/core/modules/users/auth-user-emails.server.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@ben-fornefeld ben-fornefeld merged commit 9eecf53 into main May 19, 2026
15 checks passed
@ben-fornefeld ben-fornefeld deleted the pr-15-hydrate-dashboard-user-emails-from-supabase-auth-eng-4086 branch May 19, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants